package main

import (
	"go.uber.org/fx"
	"mallgo/config"
	"mallgo/core"
	"mallgo/internal/database"
	"mallgo/internal/resources/product/controller"
	"mallgo/internal/resources/product/repository"
	"mallgo/internal/resources/product/resource"
	userController "mallgo/internal/resources/user/controller"
	userResource "mallgo/internal/resources/user/resource"
)

func main() {
	app := fx.New(
		// 加载配置
		fx.Provide(config.LoadLocal),
		// 初始化数据库
		fx.Provide(database.InitGorm),

		fx.Provide(core.NewServer),

		fx.Provide(repository.NewProductRepository),
		fx.Provide(resource.NewProductResource),
		fx.Provide(controller.NewProductController),
		fx.Invoke(controller.InitRouter),

		fx.Provide(userResource.NewUserResource),

		// 初始化路由
		fx.Invoke(userController.InitRouter),

		fx.Invoke(core.Run),
	)

	app.Run()
}
